import 'package:flutter/material.dart';

class ShadowCard extends StatelessWidget {
  final Widget child;
  final EdgeInsetsGeometry padding;
  final Color? color;
  final double elevation;
  final BorderRadiusGeometry borderRadius;
  final VoidCallback? onTap;

  const ShadowCard({
    super.key,
    required this.child,
    this.padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
    this.color,
    this.elevation = 4.0,
    this.borderRadius = const BorderRadius.all(Radius.circular(12)),
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final cardColor = color ?? theme.cardColor;

    return MouseRegion(
        cursor: SystemMouseCursors.click,
        child: Material(
            borderRadius: borderRadius,
            elevation: elevation, // 基础阴影高度
            shadowColor: Colors.black.withOpacity(0.1),
            child: InkWell(
                borderRadius: borderRadius as BorderRadius?,
                onTap: onTap,
                splashColor: onTap != null ? theme.primaryColor.withOpacity(0.1) : null,
                highlightColor: onTap != null ? theme.primaryColor.withOpacity(0.05) : null,
                child: Container(
                    decoration: BoxDecoration(
                        color: cardColor,
                        borderRadius: borderRadius,
                        border: Border.all(
                            color: Color(0xFFE4E4E7).withOpacity(0.5),
                            width: 1,
                        ),
                        boxShadow: [
                            // 更精致的内部阴影
                            BoxShadow(
                                color: Colors.black.withOpacity(0.05),
                                blurRadius: 8,
                                offset: const Offset(0, 2),
                                spreadRadius: 0,
                            ),
                        ],
                    ),
                    padding: padding,
                    child: child,
                ),
            ),
        ),
    );
  }
}